import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import Login from '../views/LoginView.vue'
import Register from '../views/RegView.vue'

const routes = [
  {
    path: '/',
    // name: 'home',
    // component: HomeView,
    redirect: '/home', // 添加重定向到/home
    children: [
      { path: '/home', component: () => import('../views/HomeView.vue') },
      // {
      //   path: '/home',
      //   name: 'home-page',
      //   component: () => import('../views/HomeView.vue'),
      //   meta: { requiresAuth: true }
      // },
      {path: '/user', component: () => import('../views/user/UserView.vue')},
    ]
  },
  {path: '/login', component: Login},
  {path: '/register', component: Register},
  {path: '/create-plan/manual', component: () => import('../views/plans/CreatePlanManual.vue')},
  {path: '/create-plan/AI', component: () => import('../views/plans/CreatePlanAI.vue')},
  // {
  //   path: '/plan/:id',
  //   component: () => import(@/views/plans/PlanDetail.vue'),
  //   props: true
  // },
  {path: '/create-plan/DeepSeek', component: () => import('../views/plans/CreatePlanDeepSeek.vue')},
  {path: '/my-plans', component: () => import('../views/plans/MyPlan.vue')},
  {path: '/my-orders', component: () => import('../views/orders/MyOrders.vue')},
  {path: '/my-map', component: () => import('../views/map/Map.vue')},
  {path: '/my-ticket', component: () => import('../views/ticket/Ticket.vue')},
  {path: '/my-shop', component: () => import('../views/shop/Shop.vue')},
  {path: '/profile', name: 'profile', component: () => import('@/views/ProfileView.vue')},
  {path: '/dashboard', component: () => import('@/views/AdminDashboard.vue')},
  {
    path: '/admin/dashboard',
    component: () => import('@/views/AdminDashboard.vue'),
  },
  {
    path: '/product/:id',
    name: 'ProductDetail',
    component: () => import('@/views/shop/ProductDetailModal.vue')
  }
]


const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
